home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 January / macformat-033.iso / mac / Shareware City / Developers / ABox.v1.8 / CPlus Files / ABPict.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-23  |  5.3 KB  |  245 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABPict.c
  15.  
  16. NAME
  17.     ABPict.c, part of the ABox project source code,
  18.     responsible for handling the AboutBox PICT class stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                netromancr@aol.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <netromancr@aol.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     9 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     28-july-94    -    ty    -    1.0.6--additions to support settable drag mgr usage
  38.                                     via the ABox Get/SetProperty methods
  39.     1-aug-94    -    ty    -    1.0.7--removed the LocalSendProc since it's not used here
  40.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  41.                             release and the associated Universal Headers from Apple:
  42.                             most methods that returned references now have "Ref" at
  43.                             the end of their methods names to prevent possible collisions
  44.                             with datatypes and classes of the same name (older versions
  45.                             of the compiler didn't have a problem with this).
  46.  
  47. */
  48.  
  49. /*===========================================================================*/
  50.  
  51. /*======= Segmentation directives ========*/
  52.  
  53. #ifdef USE_MANUAL_SEGMENTATION
  54. #pragma segment ty
  55. #endif
  56.  
  57. /*============ Header files ==============*/
  58.     
  59. #include     "ABPict.h"
  60. #include    "ABox.h"
  61.  
  62. /*=============== Globals ================*/
  63.  
  64. /*================ CODE ==================*/
  65.  
  66.  
  67. /*=============================== ABPict::ABPict ================================*/
  68. ABPict::ABPict(void)
  69. {
  70.     mResType = kABPictResource;
  71. } // end ABPict
  72.  
  73.  
  74.  
  75. /*=============================== ABPict::~ABPict ================================*/
  76. ABPict::~ABPict(void)
  77. {
  78. } // end ~ABPict
  79.  
  80.  
  81.  
  82.  
  83. /*=============================== ABPict::Draw ================================*/
  84. OSErr    ABPict::Draw(WindowPtr window)
  85. {
  86.     OSErr        error = noErr;
  87.     Rect        box;
  88.     
  89.     //    begin here...
  90.     
  91.     error = ABObject::Draw(window);
  92.     if (error == noErr)
  93.     {
  94.         
  95.         //    get the display area...
  96.         //
  97.         box = this->ObjectRect();
  98.         
  99.         //    now get the picture information
  100.         
  101.         error = this->InitializeResource();
  102.         
  103.         if (!error) 
  104.         {
  105.             //    now do the drawing...
  106.             //
  107.             ::DrawPicture ((PicHandle)this->ResourceHandleRef(), &box);
  108.             error = ::QDError();
  109.         }    //    end if block
  110.     
  111.     }
  112.  
  113.     return error;
  114.     
  115. } // end Draw
  116.  
  117.  
  118.  
  119. /*=============================== ABPict::Event ================================*/
  120. Boolean    ABPict::Event(EventRecord *event)
  121. {
  122.     Boolean        handled = false;
  123.     Point        where;
  124.     OSErr        error = noErr;
  125.     Rect        box = this->ObjectRect();
  126.     
  127.     //    begin here...
  128.     //
  129.     if (!event)
  130.         return handled;
  131.     
  132.     switch (event->what) 
  133.     {
  134.         case    mouseDown:
  135.                 //    1.0.6 ty--check to see if we're allowed to use the DragMgr
  136.                 //
  137.                 ABox *theABox = (ABox *)GetWRefCon (this->OurWindowRef());
  138.                 Boolean    useDrag = false;
  139.                 
  140.                 if (theABox)
  141.                     error = theABox->GetProperty(kABoxUseDragMgr, &useDrag, NULL);
  142.                 
  143.                 where = event->where;
  144.                 ::GlobalToLocal(&where);
  145.                 if (::PtInRect (where, &box) && 
  146.                     (::FrontWindow() == this->OurWindowRef()) && 
  147.                     ABUEnvDragMgr::IsPresent() && 
  148.                     useDrag) 
  149.                 {
  150.                     //    DragMgr stuff here!!!
  151.                     
  152.                     if (::WaitMouseMoved(event->where)) 
  153.                     {
  154.                         //    the user is trying to Drag
  155.                         //    from the field to someplace
  156.                         this->DragMgrEventRef() = event;
  157.                         error = Begin();
  158.                         error = End();
  159.                     } // end if block
  160.                 } // end if block
  161.             break;
  162.         default:
  163.             break;
  164.     } // end switch block
  165.     
  166.     return handled;
  167. } // end Event
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174. /*=============================== ABPict::Initialize ================================*/
  175. OSErr    ABPict::Initialize(void)
  176. {
  177.     OSErr                error = noErr;
  178.     Ptr                    ptr = NULL;
  179.     Size                ptrSize = 0;
  180.     
  181.     //    OVERRIDE of the ABUEnvDragMgr method!
  182.     if (this->IsDragInitialized())
  183.         return noErr;
  184.     
  185.     this->DragRectRef() = this->ObjectRect();
  186.     error = ABUEnvDragMgr::Initialize();
  187.     if (error)
  188.         return error;
  189.  
  190.     error = ::SetDragSendProc (this->DragRef(),
  191.                             this->DragUPPRef(),
  192.                             this);
  193.     if (error)
  194.         return error;
  195.     
  196.     //    now create the Send information
  197.     ::HLock (this->ResourceHandleRef());
  198.     ptr = *(this->ResourceHandleRef());
  199.     ptrSize = ::GetHandleSize(this->ResourceHandleRef());
  200.     
  201.     error = ::AddDragItemFlavor(this->DragRef(),
  202.                                 this->ItemRef(),
  203.                                 kABPictResource,
  204.                                 ptr,
  205.                                 ptrSize,
  206.                                 kABdefaultFlavorFlags);
  207.     ::HUnlock (this->ResourceHandleRef());
  208.     
  209.     this->DragInitializedRef() = true;    
  210.     
  211.     return error;
  212.  
  213. }    // end Initialize
  214.  
  215.  
  216.  
  217.  
  218.  
  219. /*=============================== ABPict::Begin ================================*/
  220. OSErr    ABPict::Begin(void)
  221. {
  222.     OSErr    error;
  223.     
  224.     //    OVERRIDE of the ABUEnvDragMgr method! but be certain to call
  225.     //    the ABUEnvDragMgr method when finished here!!!!
  226.     
  227.     error = Initialize();
  228.     if (error)
  229.         return error;
  230.         
  231.     error = ABUEnvDragMgr::Begin();
  232.     
  233.     return error;
  234.  
  235. }    // end Begin
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243. //    end of file
  244.  
  245.